#include<stdio.h>
#include<string.h>
int main(){
	int n,l,k,y,min,sum[100];
	int a,b,c,i;
	char naruto[100];
	memset(sum,0,sizeof(sum));
	scanf("%d",&n);
	scanf("%d",&l);
	scanf("%d",&k);
	scanf("%d",&y);
	a=l+k+y;
	b=2*l+k;
	c=3*l+3*k+2*y;
	for(i=0;i<n;i++){
		scanf("%s",naruto);
		int len,j;
		len=strlen(naruto);
		for(j=0;j<len;j++){
			if(naruto[j]=='A')
			sum[i]+=a;
			else if(naruto[j]=='B')
			sum[i]+=b;
			else if(naruto[j]=='C')
			sum[i]+=c;
		}
	}
	min=sum[0];
	for(i=0;i<n;i++){
	if(min>sum[i])
	min=sum[i];
}
printf("%d\n",min);
}
